package com.cskaoyan.controller;

import com.cskaoyan.bean.User;
import com.cskaoyan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @author stone
 * @date 2022/04/30 10:02
 */
@RestController
@RequestMapping("user")
public class UserController {

    //UserMapper userMapper;
    @Autowired
    UserService userService;

    @RequestMapping("register")
    public User add(String username, String password, Integer age, Date birthday, String mobile) {
        User user = new User(null, username, password, age, birthday, new Date(), mobile);
        userService.add(user);
        return user;
    }

    @RequestMapping("query")
    public List<User> query(String username) {
        return userService.query(username);
    }
}
